<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${basePackage}.mapper.${className}Mapper">

	<sql id="Base_Query_Where" >
		<#list attrs as attr>
		<#if attr.busiItemType == 1>
		<#if attr.typeName?contains("Date")>
		<if test="entity.${attr.camelName}Begin != null">
			and t.${attr.columnName}<#noparse> &gt;= #{entity.</#noparse>${attr.camelName}Begin<#noparse>}</#noparse>
		</if>
		<if test="entity.${attr.camelName}End != null">
			and t.${attr.columnName}<#noparse> &lt;= #{entity.</#noparse>${attr.camelName}End<#noparse>}</#noparse>
		</if>
		<#else>
		<#if attr.ctrl.likeQuery = "Y">
		<if test="entity.${attr.camelName} != null and entity.${attr.camelName} != ''">
			and t.${attr.columnName} like concat('%',<#noparse>#{entity.</#noparse>${attr.camelName}<#noparse>}</#noparse>,'%')
		</if>
		<#else>
		<#if attr.typeName?contains("String")>
		<if test="entity.${attr.camelName} != null and entity.${attr.camelName} != ''">
			and t.${attr.columnName} = <#noparse>#{entity.</#noparse>${attr.camelName}<#noparse>}</#noparse>
		</if>
		<#else>
		<if test="entity.${attr.camelName} != null">
			and t.${attr.columnName} = <#noparse>#{entity.</#noparse>${attr.camelName}<#noparse>}</#noparse>
		</if>
		</#if>
		</#if>
		<#if attr.ctrl.batchQuery = "Y">
		<if test="entity.${attr.camelName}List != null and entity.${attr.camelName}List.size() > 0">
            and t.${attr.columnName} in
			<foreach collection="entity.${attr.camelName}List" item="${attr.camelName}ListValue" index="${attr.camelName}Index"  open="(" close=")"  separator=",">
				<#noparse>#{</#noparse>${attr.camelName}ListValue<#noparse>}</#noparse>
			</foreach>
		</if>
		</#if>
		</#if>
		</#if>
		</#list>

	</sql>

	<select id="queryList" resultType="${basePackage}.model.${className}Bean" parameterType="${basePackage}.model.${className}Bean">
        select t.*	from ${tableName} t where t.is_deleted = 0
		<include refid="Base_Query_Where"/>
		order by t.create_time desc
	</select>

	<select id="queryPageList" resultType="${basePackage}.model.${className}Bean" parameterType="${basePackage}.model.${className}Bean">
		select t.*	from ${tableName} t where t.is_deleted = 0
		<include refid="Base_Query_Where"/>
        order by t.create_time desc
	</select>
</mapper>